import Layout from '@/views/Layout'
import Detail from '@/views/Detail'
import Home from '@/views/Home'
import Collect from '@/views/Collect'
import Like from '@/views/Like'
import My from '@/views/My'
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
const router = new VueRouter({
  routes: [
    { 
      path: '/', 
      component: Layout,
      redirect: '/home',
      // 二级路由写在 children中  path 不需要加/
      // 二级路由出口一定在他的父组件中 (<router-view/>)
      children: [
        {
          path: 'home',
          component: Home
        },
        {
          path: 'collect',
          component: Collect
        },
        {
          path: 'like',
          component: Like
        },
        {
          path: 'my',
          component: My
        }
      ]
    },
    {path: '/detail/:id', component: Detail},
  ],
  // 配置history路由模式     路由模式默认是hash模式
  mode: "history" // 
})

export default router